import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;


public class inregistrare extends JFrame
{
	private static final long serialVersionUID = 1L;
	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;
	private JTextField jTextField = null;
	private JTextField jTextField1 = null;
	private JTextField jTextField2 = null;
	private JButton jButton = null;
	int widthWindow;
	int heightWindow;

	public inregistrare() {
		super();
		initialize();
	}

	private void initialize() {
        this.setSize(new Dimension(280, 240));
        this.setContentPane(getJPanel());
        this.setTitle("Inregistrare");
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);			
	}

	private JPanel getJPanel() {
		if (jPanel == null) {
			
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(35, 30, 85, 20));
			jLabel.setText("Nume:");
			
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(35, 60, 85, 20));
			jLabel1.setText("Prenume:");
			
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(35, 90, 85, 20));
			jLabel2.setText("CNP:");
			
			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(35, 155, 300, 20));
			
			
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.add(jLabel, null);
			jPanel.add(jLabel1, null);
			jPanel.add(jLabel2, null);
			jPanel.add(jLabel3, null);
			jPanel.add(getJTextField(), null);
			jPanel.add(getJTextField1(), null);
			jPanel.add(getJTextField2(), null);
			jPanel.add(getJButton(), null);
		}
		return jPanel;
	}

	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setBounds(new Rectangle(135, 30, 100, 20));
		}
		return jTextField;
	}

	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
			jTextField1.setBounds(new Rectangle(135, 60, 100, 20));
		}
		return jTextField1;
	}

	private JTextField getJTextField2() {
		if (jTextField2 == null) {
			jTextField2 = new JTextField();
			jTextField2.setBounds(new Rectangle(135, 90, 100, 20));
		}
		return jTextField2;
	}

	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setBounds(new Rectangle(86, 125, 105, 25));
			jButton.setText("Start");
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e)
				{
					if (jTextField.getText().equals(""))
						{
							System.out.println("Trebuie sa introduceti numele!");
							//jLabel3.setText("");
							jLabel3.setText("Trebuie sa introduceti numele!");
							jLabel3.invalidate();
							validate();
						}
					else if (jTextField1.getText().equals(""))
						{
							System.out.println("Trebuie sa introduceti prenumele!");
							//jLabel3.setText("");
							jLabel3.setText("Trebuie sa introduceti prenumele!");
							jLabel3.invalidate();
							validate();
						}
					else if (jTextField2.getText().equals(""))
						{
							System.out.println("Trebuie sa introduceti CNP!");
							jLabel3.setText("Trebuie sa introduceti CNP!");
							jLabel3.invalidate();
							validate();
						}
					else
						{
							principal.inregistreaza(jTextField.getText(), jTextField1.getText(), jTextField2.getText());
					
						}
				}
			});
		}
		return jButton;
	}

}  
